﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Library
{
    public class Phom
    {
        public static int KT(List<LaBai> list)
        {
            int count = 0;
            string[] a = new string[3];
            foreach (var item in list)
            {
                if (BoBa(item.So, list) == 1 && (count == 0 || !Compare(item.So, a)))
                {
                    a[count] = item.So;
                    count += 1;
                }
            }
            return count;
        }
        public static bool Compare(string ob1, string[] ob2)
        {
            bool flag = false;
            Array.ForEach(ob2, p =>
            {
                if (p == ob1)
                    flag = true;
            });
            return flag;
        }
        private static int BoBa(string so, List<LaBai> list)
        {
            int dem = 0;
            var kq = list.FindAll(p => p.So == so);
            if (kq.Count >=3)
                dem++;
            return dem;
        }
        public static int PhomGiay(List<LaBai> list)
        {
            var s = from b in list
                    from c in list
                    from d in list
                    where b.So.CompareTo(c.So) == -1 && c.So.CompareTo(d.So) == -1 && b.Ten == c.Ten && c.Ten == d.Ten
                    select new { b, c, d };
            return s.ToList().Count;
        }
    }
}
